<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

/**
 * Class InterestRecord
 * 
 * @property int $id
 * @property int|null $order_id
 * @property int|null $branch_id
 * @property Carbon|null $date
 * @property Carbon|null $next_date
 * @property float|null $interest
 * @property float|null $money
 * @property float|null $payment_amount
 * @property float|null $interest_money
 * @property Carbon|null $real_time
 * @property int|null $type
 * @property int|null $status
 * @property int|null $is_exit
 * @property int|null $message_remind
 * @property int|null $num
 * @property int|null $num_all
 * @property Carbon|null $create_time
 * @property Carbon|null $update_time
 * @property string|null $bank_num
 * @property string|null $open_bank
 * @property string|null $user_name
 * @property string|null $account_name
 * @property string|null $bank_name
 * @property int|null $receivable_type
 * @property string|null $receivable_no
 * 
 * @property Branch|null $branch
 * @property Order|null $order
 * @property Collection|OrderRecord[] $order_records
 *
 * @package App\Models
 */
class InterestRecord extends Model
{
	protected $table = 'interest_record';

	protected $casts = [
		'order_id' => 'int',
		'branch_id' => 'int',
		'interest' => 'float',
		'money' => 'float',
		'payment_amount' => 'float',
		'interest_money' => 'float',
		'type' => 'int',
		'status' => 'int',
		'is_exit' => 'int',
		'message_remind' => 'int',
		'num' => 'int',
		'num_all' => 'int',
		'receivable_type' => 'int'
	];

	protected $dates = [
		'date',
		'next_date',
		'real_time'
	];

	protected $fillable = [
		'order_id',
		'branch_id',
		'date',
		'next_date',
		'interest',
		'money',
		'payment_amount',
		'interest_money',
		'real_time',
		'type',
		'status',
		'is_exit',
		'message_remind',
		'num',
		'num_all',
		'bank_num',
		'open_bank',
		'user_name',
		'account_name',
		'bank_name',
		'receivable_type',
		'receivable_no'
	];

	public function branch()
	{
		return $this->belongsTo(Branch::class);
	}

	public function order()
	{
		return $this->belongsTo(Order::class);
	}

	public function order_records()
	{
		return $this->hasMany(OrderRecord::class, 'ir_id');
	}
}
